import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/Login.vue'
import Error from '../views/Error.vue'
import Sign from '../views/Sign.vue'
import Guide from '../views/Guide/Index.vue'
import Friend from '../views/friend/Index.vue'
import Video from '../views/Video/index.vue'
import Message from '@/views/Message.vue'
import System from '@/components/Message/System.vue'
import Inquiry from '@/components/Message/Inquiry.vue'
import Coin from '@/components/Message/Coin.vue'
import Search from '@/views/Search/index.vue'
import My from '@/views/my/Index.vue'
import Mxgy from '@/views/disease/Mxgy/mxgy.vue'
import Userxx from '../views/friend/deitail/userxx/Index.vue'
import Writepyq from '../views/friend/writepyq/Index.vue'
import Disease from '@/views/disease/Disease.vue'
import Deitail from '@/views/friend/deitail/Index.vue'
import WriteFritend from '@/views/friend/WriteFritend.vue'
import File from '@/views/My/File/index.vue'
import Purse from '@/views/My/Purse/index.vue'
import Collect from '@/views/My/Collect/index.vue'
import Proposal from '@/views/My/Proposal/index.vue'
import My_Video from '@/views/My/Video/index.vue'
import Circle from '@/views/My/Circle/index.vue'
import Follow from '@/views/My/Follow/index.vue'
import Task from '@/views/My/Task/index.vue'
import Set from '@/views/My/Sset/index.vue'
import Forget from '@/views/Forget.vue'
import New_Password from '@/views/NewPws/index.vue'

import About_us from '@/views/My/Sset/About-us/index.vue'
// import Cersion


import Girl from '@/views/girl/Index.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [//重定向
    {
      path: '/',
      component: Guide
    },
    {
      path: '/guide',
      component: Guide
    },
    {
      path: '/home',
      component: Home,
      
    },
    {
      path: '/home/disease',
      component: Disease
    },
    {
      path: '/message',
      component: Message
    },
     {
      path:'/home/disease',
      component: Disease
    },
      {
      path:'/home/disease/mxgy',
      component:Mxgy
    },
        {
       path:"/home/search",
      component:Search
    },
    {
      path:'/message',
      component: Message
    },
    {
      //系统信息
      path:'/message/system',
      component: System
    },
        {
      //问诊信息
      path:'/message/inquiry',
      component: Inquiry
    },
      {
      //h币信息
      path:'/message/coin',
      component: Coin
    },
 
    {
      path: '/home/disease',
      component: Disease
    },
    {
      path:'/friend',
      component:Friend
    },
    {
      path: '/message',
      component: Message
    },
   
    {
      path:'/girl',
      component:Girl
    },
    {
      path: '/friend/detail',
      component: Deitail
    },
    {
      path:'/friend/detail/userxx',
      component: Userxx
    },

    {
      path:'/friend/writepyq',
      component:Writepyq
    },
    {
      path:'/friend/writefritend',
      component:WriteFritend
    },
    {
      path:"/home/search",
      component:Search
    },
    {
      path:'/video',
      component: Video
    },
    {
      path: '/my',
      component: My
    },
    {
      //我的档案
      path: '/my/file',
      component: File
    },
    {
      path:"/my/purse",
      component: Purse
    },
    {
      path:"/my/collect",
      component: Collect
    },
    {
      path:"/my/proposal",
      component: Proposal
    },
    {
      path:"/my/video",
      component: My_Video
    },
    {
      path:"/my/circle",
      component: Circle
    },
    {
      path:"/my/follow",
      component: Follow
    },
    {
      path:"/my/task",
      component: Task
    },
    {
      path:"/my/set",
      component: Set
    },
      {
      path: '/home/disease',
      component: Disease
    },
    {
      path: '/set',
      component: Set
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/sign',
      component: Sign
    },
    {
      path: '/forget',
      component: Forget
    },
    {
      path:"/new_password",
      component:New_Password
    },
    { 
      path: '/:pathMatch(.*)*',
      component: Error
    },
  ]
})
//守卫
router.beforeEach((to, from) => {
  if (to.path != '/login' && to.path != '/sign'&& to.path != '/forget'&& to.path != '/new_password') {
    const token = localStorage.getItem('token')
    if (!token) {
      return {
        path: "/login"
      }
    }
  }

})
export default router
